/***
 * @Description:
 * @Author: LI Yihong
 * @Email: liyh@jihua.ac.cn
 * @Date: 2024-09-29 12:10:18
 * @LastEditTime: 2024-09-29 12:10:29
 * @LastEditors: LI Yihong
 * @FilePath: \RT_Stm32F7\applications\test\threadCtrl.h
 */
#pragma once
#include "armKeyTest.h"
#include "printTest.h"
#include "led.h"
#include "Semaphore.h"
#include "Mail.h"
#include "Queue.h"
#include <string>
#include <vector>
#include <memory>

using namespace std;

class ThreadCtrl
{
private:
    // thread
    unique_ptr<ArmKey> armKey;
    unique_ptr<PrintTest> printTest;
    unique_ptr<LED> led;
    void threadInit();
    void threadStart();
    void semInit();
    void mailInit();
    void QueueInit();

public:
    static ThreadCtrl &getInstance();

    // semaphore
    shared_ptr<Semaphore> buttonSem;
    shared_ptr<Semaphore> ledSem;

    // mail
    shared_ptr<Mail<std::string, 10>> buttonMail;

    // message queue
    shared_ptr<Queue<int, 10>> buttonQueue;

private:
    ThreadCtrl();
    ~ThreadCtrl();
    ThreadCtrl(const ThreadCtrl &) = delete;
    ThreadCtrl &operator=(const ThreadCtrl &) = delete;
};
